package com.github.mikephil.chart_3_0_1v.data;

import android.annotation.SuppressLint;
import android.util.Log;

/**
 * Created by Philipp Jahoda on 31/05/16.
 */
@SuppressLint("ParcelCreator")
public class PieEntry extends Entry {

    private String label;

    /**
     * 用来标记是否显示描述文字
     */
    private boolean display = true;

    public PieEntry(float value) {
        super(0f, value);
    }

    public PieEntry(float value, Object data) {
        super(0f, value, data);
    }

    public PieEntry(float value, String label) {
        super(0f, value);
        this.label = label;
    }

    public PieEntry(float value, String label, Object data) {
        super(0f, value, data);
        this.label = label;
    }

    /**
     * 当传数据过小，调用此方法不显示文字
     * @param value
     * @param label
     * @param display
     */
    public PieEntry(float value ,String label,boolean display){
        super(0f,value);
        this.label = label;
        this.display = display;
    }
    /**
     * This is the same as getY(). Returns the value of the PieEntry.
     *
     * @return
     */
    public float getValue() {
        return getY();
    }

    public String getLabel() {
        return label;
    }

    /**
     * 文字绘制时用到做判断
     * @return
     */
    public boolean isDisplay() {
        return display;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * 设置display值，达到控制是否显示文字
     * @param display
     */
    public void setDisplay(boolean display) {
        this.display = display;
    }

    @Deprecated
    @Override
    public void setX(float x) {
        super.setX(x);
        Log.i("DEPRECATED", "Pie entries do not have x values");
    }

    @Deprecated
    @Override
    public float getX() {
        Log.i("DEPRECATED", "Pie entries do not have x values");
        return super.getX();
    }

    public PieEntry copy() {
        PieEntry e = new PieEntry(getY(), label, getData());
        return e;
    }
}
